package application.view 
{
	import application.ApplicationFacade;
	import application.view.*;
	import ginger.events.DataEvent;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	
	/**
	 * 程序总视图
	 * @author Ning
	 */
	public class ApplicationMediator extends Mediator
	{
		public static const NAME:String = 'ApplicationMediator';
		
		public function ApplicationMediator(application:Application) 
		{
			super(NAME, application);
		}
		private function get app():Application
		{
			return viewComponent as Application;
		}
		override public function onRegister():void 
		{
			facade.registerMediator(new GroupMediator(app.groupCombobox));
			facade.registerMediator(new PhotoAreaMediator(app.photoArea));
			facade.registerMediator(new PhotoViewMediator(app.photoView));
			facade.registerMediator(new MainNavMediator(app.mainNavView));
			facade.registerMediator(new ModuleMediator(app.moduleView));
		}
		override public function handleNotification(notification:INotification):void 
		{
			switch(notification.getName())
			{
				case ApplicationFacade.UPDATE_LAYOUT_CONFIG:
				app.updateLayoutConfig(notification.getBody());
				break;
				case ApplicationFacade.SHOW_PHOTO_VIEW:
				app.showPhoto();
				break;
				case ApplicationFacade.SHOW_PHOTO_AREA:
				app.showPhotoArea();
				break;
			}
		}
		override public function listNotificationInterests():Array 
		{
			return [ApplicationFacade.UPDATE_LAYOUT_CONFIG,ApplicationFacade.SHOW_PHOTO_VIEW,ApplicationFacade.SHOW_PHOTO_AREA]
		}
	}
}